
/**
	Author	     :  Varma
	Date	     :  Oct 21th, 2004
 	Description  :  This proc updates the Invoice number and Invoice Generated fields in CST and CSLIT
			tables in CT.
	Usage        :  exec sp_ct_update_invoice_info 'IVC00000000000023'
			
*/

alter  proc sp_ct_update_invoice_info
@invoice_no varchar(50)
AS
begin
	declare @temp_cst_id int

	declare lineItemCursor CURSOR FOR

	select  CustomerShipping_ID from Customer_Shipping_Table where Inv_No = @invoice_no 	
	open lineItemCursor 
	fetch next from lineItemCursor into @temp_cst_id
	while @@fetch_status = 0		
	begin
		Update Customer_Shipping_Table Set Inv_No = '' Where CustomerShipping_ID = @temp_cst_id

		Update Customer_Shipping_Line_Item_Table Set Invoice_Generated = 1 Where CustomerShipping_ID = @temp_cst_id
	
	fetch next from lineItemCursor into @temp_cst_id 
	end
	close lineItemCursor
	deallocate lineItemCursor
end


